﻿using M_Purchase.Api.Appliction.Command.PurchCommand;
using M_Purchase.Repository.PurchaseInterface;
using MediatR;

namespace M_Purchase.Api.Appliction.CommandHandlers.PurchCommandHandler
{
    /// <summary>
    /// 修改物流信息
    /// </summary>
    public class LogisticsUpdateCommandHandler : IRequestHandler<LogisticsUpdateCommand, int>
    {
        private readonly ILogisticsRepository _logisticsRepository;
        public LogisticsUpdateCommandHandler(ILogisticsRepository logisticsRepository)
        {

            _logisticsRepository = logisticsRepository;
        }
        public async Task<int> Handle(LogisticsUpdateCommand request, CancellationToken cancellationToken)
        {
            var LogList = await _logisticsRepository.GetModelsAsync(request.LogisticsId);
            LogList.Sarte = "运输中";
            LogList.endDate = DateTime.Now.AddDays(3);
            LogList.sendDate= DateTime.Now;
            LogList.LogisticsName = "祥顺物流有限公司";
            return await _logisticsRepository.UpdateAsync(LogList);
             
        }
    }
}
